package com.government.quartz.task;

import com.government.member.domain.Vip;
import com.government.member.service.VipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Component("vipTask")
@Transactional(rollbackFor = Exception.class)
public class VipTask {

    @Autowired
    private VipService vipService;

    /**
     * vip过期处理
     */
    public void vipExpiredHandler() {
        List<Vip> vipList = vipService.selectExpiredVip();
        for (Vip vip : vipList) {
            vip.setUpdateTime(new Date());
            vip.setStatus("2");
            vipService.updateVip(vip);
        }
    }
}
